<template>
  <div class="lower-wrapper">
    <div class="invite-title"><a href="javascript:;" @click="returnHref"><img src="../../assets/img/return.png"></a><p>新增扫码玩家</p></div>
    <div class="lower-head">
      <ul>
        <li>
          <label>类型</label>
          <el-select v-model="agentType" placeholder="类型" class="lower-type" size="small">
            <el-option
              v-for="item in options2"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              :disabled="item.disabled">
            </el-option>
          </el-select>
        </li>
        <li><h3>全部人数：<span>{{total}}</span>人</h3></li>
        <li><a href="javascript:;" @click="getLower">查询</a></li>
      </ul>
    </div>
    <div class="lower-content">
      <el-table
        :data="tableData"
        v-loading="listLoading"
        stripe
        style="width: 100%">
        <el-table-column
          fixed
          prop="userid"
          label="玩家ID"
          width="80">
        </el-table-column>
        <el-table-column
          prop="nickname"
          label="玩家昵称"
          min-width="100">
          <template slot-scope="scope">
            <span >{{scope.row.nickname | baseName}}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="type"
          label="类型"
          width="50">
          <template slot-scope="scope">
            <span v-text="scope.row.isAgent ? '代理':'玩家'"></span>
          </template>
        </el-table-column>
        <el-table-column
          prop="time"
          label="创建时间"
          width="160">
        </el-table-column>
      </el-table>
      <el-pagination
        background
        :pager-count="5"
        layout="prev, pager, next"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
  import base64 from '../../api/base64'
    export default {
        name: "scan",
      data(){
          return{
            options2: [
              {
                value: '0',
                label: '所有'
              }, {
                value: '1',
                label: '代理'
              }, {
                value: '2',
                label: '玩家'
              }
            ],
            agentType: '0',
            agentId:'',
            pageIndex:1,
            pageSize:this.global().pageSize,
            total:0,
            listLoading:false,
            tableData: [
              // {userid: '5450200', nickname: '王小虎王小虎王小虎', type: '0', time:'2018-11-16 00:00:00'},
              // {userid: '545020', nickname: '阿斯蒂芬', type: '1', time:'2018-11-16'},
              // {userid: '545020', nickname: '撒旦法', type: '1', time:'2018-11-16'},
              // {userid: '545020', nickname: '歌功颂德', type: '0', time:'2018-11-16'}
            ]
          }
      },
      created(){
          this.getLower()
      },
      methods:{
        returnHref(){
          this.$router.go(-1)
        },
        getLower(){
          this.listLoading = true;
          this.$axios.get('/today/sub-users?usertype='+this.agentType+'&index='+this.pageIndex+'&size='+this.pageSize,{},this.global().token).then((res)=>{
            if(res.status == 200){
              let userData = res.data.data
              this.total = res.data.count
              userData.forEach((val)=>{
                if (!(val.registerat== '0' || val.registerat == '')){
                  val.time = this.changeDate(val.registerat)
                  }
              })
              this.tableData = userData
              this.listLoading = false;
            }
          })
        },
      }
    }
</script>

<style scoped lang="stylus">
  @import "../../assets/css/title.styl"
  @import "../../assets/css/table.styl"
</style>
